Visit https://posit.cloud/content/5458223 to access the workshop material.
Note
If you do not yet have a posit Cloud (previously known as Rstudio Cloud) account, you will have to sign up!
<-We assign objects in R using the syntax object_name <- value
Note
This is analogous to object type. We can assign names to variables, vectors, matrices, dataframes, graphs, statistical models, etc. with <-.
# A tibble: 344 × 8
species island bill_length_mm bill_depth_mm flipper_…¹ body_…² sex year
<fct> <fct> <dbl> <dbl> <int> <int> <fct> <int>
1 Adelie Torgersen 39.1 18.7 181 3750 male 2007
2 Adelie Torgersen 39.5 17.4 186 3800 fema… 2007
3 Adelie Torgersen 40.3 18 195 3250 fema… 2007
4 Adelie Torgersen NA NA NA NA <NA> 2007
5 Adelie Torgersen 36.7 19.3 193 3450 fema… 2007
6 Adelie Torgersen 39.3 20.6 190 3650 male 2007
7 Adelie Torgersen 38.9 17.8 181 3625 fema… 2007
8 Adelie Torgersen 39.2 19.6 195 4675 male 2007
9 Adelie Torgersen 34.1 18.1 193 3475 <NA> 2007
10 Adelie Torgersen 42 20.2 190 4250 <NA> 2007
# … with 334 more rows, and abbreviated variable names ¹flipper_length_mm,
# ²body_mass_g
Learn more about the data!
Learn more about the palmer penguins data set here.
Okay, but that’s kind of boring and doesn’t look quite right…
ggplot(data = penguins,
mapping = aes(x = bill_length_mm,
y = bill_depth_mm,
color = species,
shape = species
)
) +
geom_point() +
geom_smooth(method = "lm") +
labs(x = "Bill Length (mm)",
y = "Bill depth (mm)",
title = "Penguin Bill Size",
color = "Species",
shape = "Species"
) +
scale_color_brewer(palette = "Dark2") +
scale_x_continuous(limits = c(30, 60),
breaks = seq(30,60,10)
) +
scale_y_continuous(limits = c(10, 25),
breaks = seq(10,25,5)
)ggplot(data = penguins,
mapping = aes(x = bill_length_mm,
y = bill_depth_mm,
color = species,
shape = species
)
) +
geom_point() +
geom_smooth(method = "lm") +
labs(x = "Bill Length (mm)",
y = "Bill depth (mm)",
title = "Penguin Bill Size",
color = "Species",
shape = "Species"
) +
scale_color_brewer(palette = "Dark2") +
scale_x_continuous(limits = c(30, 60),
breaks = seq(30,60,10)
) +
scale_y_continuous(limits = c(10, 25),
breaks = seq(10,25,5)
) +
theme_bw()ggplot(data = penguins,
mapping = aes(x = bill_length_mm,
y = bill_depth_mm,
color = species,
shape = species
)
) +
geom_point() +
geom_smooth(method = "lm") +
facet_wrap(~ island) +
labs(x = "Bill Length (mm)",
y = "Bill depth (mm)",
title = "Penguin Bill Size",
color = "Species",
shape = "Species"
) +
scale_color_brewer(palette = "Dark2") +
scale_x_continuous(limits = c(30, 60),
breaks = seq(30,60,10)
) +
scale_y_continuous(limits = c(10, 25),
breaks = seq(10,25,5)
) +
theme_bw()Create a personal website with {Blogdown} or {Porfoliodown}
Write a book with {Bookdown}
And so much more!
Download and run the R installer for your operating system from CRAN:
If you are on Windows, you should also install the Rtools4 package; this will ensure you get fewer warnings later when installing packages.
More detailed instructions for Windows are available here
Download and install the latest version of RStudio for your operating system.